/*
 Lambda 
 File: Vector3.h
 Author: Srinath R 
 Created: Sep 2010
 Last modified: Sep 2010
*/

#ifndef __VECTOR3_H__
#define __VECTOR3_H__

#pragma once
#include<iostream>

/*
 Class: Vector3
 Description: 3-component vector class in the (x,y,z) format
*/

class Vector3
{
public:
	//public data members
	float x,y,z;

	//constructors
	
	//Default constructor
	Vector3();

	//Floating point initialization
	Vector3(float x, float y, float z);

	//Public member functions
	void Normalize();						// Normalize a given vector
	float Length();							// Get the lenght of the vector
	float AbsLength();						// Get the Absolute length of the vector
	Vector3 GetNormalizedVector() const;	// Get a new normalized vector from this vector

	// Overloaded operators
	Vector3 operator - ();					// Negate the components of a vector
	Vector3 operator + (const Vector3& V2); // Add a vector to this vector
	Vector3 operator - (const Vector3& V2); // Subtract a vector from this vector
	Vector3 operator * (float k);			// Scale a vector by a scalar k
	Vector3 operator / (float k);			// Scale a vector by the inverse of scalar k
	float operator * (const Vector3& V2);	// Dot product
	Vector3 operator ^ (const Vector3& V2);	//cross product
	
	// Friend functions

	/*
	 Function: operator *()
	 Desc: Multiply a vector by a scalar
	 Parameters: Scalar(k), Vector3(V)
	*/
	friend Vector3 operator * (float k, const Vector3& V) { return Vector3(k*V.x, k*V.y, k*V.z); }
	
	
	friend void operator << (std::ostream& op, const Vector3& V)
	{
		op<<V.x<<" "<<V.y<<" "<<V.y;
	}
	
	friend float operator * (const Vector3& V1, const Vector3& V2) { return (V1.x*V2.x + V1.y*V2.y + V1.z*V2.z); }
	friend Vector3 operator ^ (const Vector3& V1, const Vector3& V2) { return Vector3((V1.y*V2.z - V1.z*V2.y), (V1.z*V2.x - V1.x*V2.z), (V1.x*V2.y - V1.y*V2.x)); }

	
	
};

//End of Vector3 class

#endif